package action.fkgl;
import java.util.ArrayList;

import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import services.fkgl.DwdjServices;
import com.util.Component;
import com.PublicSystem;
import com.util.Util;
import com.syslog.SysLogServices;
/**
 * 单位发卡管理
 * @author duy
 *
 */
@Controller
@RequestMapping("DWfk.do")
public class DwdjAction {
	PublicSystem sys = PublicSystem.getInstance();
	DwdjServices ss = new DwdjServices();
	SysLogServices log = SysLogServices.getInstance();
	/**
	 * 校验单位发卡数据
	 * @author duy
	 * @param obj
	 * @param parms
	 * @throws Exception
	 */
	@RequestMapping(params ="method=checkDWfk")
	public void checkDWfk(HttpServletRequest request, HttpServletResponse response) throws Exception {
    	String aab001 = request.getParameter("id");
    	String aae011 = Component.getSession("userid", request);
    	HashMap map = new HashMap();
    	map.put("aab001", aab001);
    	map.put("aae011",aae011);
    	HashMap m = ss.checkDWfk(map);
		Component.print(Util.Encode(m), response);		
		String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
   		HashMap obj = new HashMap();
   		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
   		obj.put("log_type", "T05");   //日志类别，见sys_log_bm
   		obj.put("userid", userid);    //操作人
  		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
   		obj.put("content", "用户" + userid + "校验" + "劳动保障卡号为" + aab001 + "的单位信息");  //日志内容，自己组合拼装
   		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
   		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
   		obj.put("datain", userid);    //输入参数
   		obj.put("dataout", Util.Encode(m));//输出参数
  		log.sysLogMap(obj, request);				
	}	
	/**
	 * 查询单位发卡数据
	 * @author duy
	 * @param obj
	 * @param parms
	 * @throws Exception
	 */
	@RequestMapping(params ="method=getDWfk")
	public void getDWfk(HttpServletRequest request, HttpServletResponse response) throws Exception {
    	String eventId = request.getParameter("eventId");
    	HashMap parms = sys.getGridSort(request);
	    String json = Util.Encode(ss.getDWfk(new Object[] {eventId}, parms));
	    Component.print(json, response);	    
	    String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
   		HashMap obj = new HashMap();
   		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
   		obj.put("log_type", "T05");   //日志类别，见sys_log_bm
   		obj.put("userid", userid);    //操作人
  		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
   		obj.put("content", "用户" + userid + "查询" + "编号为"+ eventId + "的单位信息");  //日志内容，自己组合拼装
   		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
   		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
   		obj.put("datain", userid);    //输入参数
   		obj.put("dataout", json);//输出参数
  		log.sysLogMap(obj, request);	    	      
	}	
	/**
	 * 根据id获取单位信息,判断是否存在符合条件的数据
	 * @author duy 
	 * @param request
	 * @param response
	 *@throws Exception
	 */
	@RequestMapping(params ="method=getDWfk1")
	public void getDWfk1(HttpServletRequest request, HttpServletResponse response) throws Exception {
		HashMap user = ss.getDWfk1(Component.getQuest("eventId", request));
    	Component.print(Util.Encode(user), response);
	}	
	/**
	* 查询发卡详细信息
	* @author duy
	* @param request
	* @param response
	*@throws Exception
	*/ 
	@RequestMapping(params ="method=getDWfkmx")
	public void getDWfkmx(HttpServletRequest request, HttpServletResponse response) throws Exception {		
		String aab001 = request.getParameter("aab001");
		String aaz001 = Component.getQuest("aaz001", request);
		String aaz002 = Component.getQuest("aaz002", request);
	    HashMap parms = sys.getGridSort(request);
	    String json = Util.Encode(ss.getDWfkmx(new Object[] {aab001, aaz001, aaz002}, parms));
	    Component.print(json, response);	    
	    String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
   		HashMap obj = new HashMap();
   		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
   		obj.put("log_type", "T05");   //日志类别，见sys_log_bm
   		obj.put("userid", userid);    //操作人
  		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
   		obj.put("content", "用户" + userid + "查询" + "社会保障卡号为"  +aaz001 + "的详细信息");  //日志内容，自己组合拼装
   		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
   		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
   		obj.put("datain", userid);    //输入参数
   		obj.put("dataout", json);//输出参数
  		log.sysLogMap(obj, request);	    	    
	}	
	/**
	 * 保存单位发卡人员信息
	 * @author duy 
	 * @param request
	 * @param response
	 *@throws Exception
	 */
	@RequestMapping(params ="method=saveDWfk")
	public void saveDWfk(HttpServletRequest request, HttpServletResponse response) throws Exception {
		   String json=request.getParameter("data");
		   String aae011 = Component.getSession("userid", request);
		   String aab001 = request.getParameter("aab001");
	       ArrayList rows = (ArrayList)Util.Decode(json);
	       HashMap row = (HashMap)rows.get(0);
	       row.put("aae011", aae011);
	       row.put("aab001", aab001);
	       Component.print(ss.saveDWfk(row), response);	       
	       String userid = Component.getSession("userid", request);
		   String rwid = Component.getSession("rwid", request);
	   	   HashMap obj = new HashMap();
	   	   obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
	   	   obj.put("log_type", "T02");   //日志类别，见sys_log_bm
	   	   obj.put("userid", userid);    //操作人
	  	   obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
	   	   obj.put("content", "用户" + userid + "发放" + "制卡批次为" + aab001 + "的数据");  //日志内容，自己组合拼装
	   	   obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
	   	   obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
	   	   obj.put("datain", userid);    //输入参数
	   	   obj.put("dataout", ss.saveDWfk(row));//输出参数
	  	   log.sysLogMap(obj, request);
	}			
}
